$(document).ready(function () {
    tdzzs.onload();
})

var tdzzs = (function () {

    var init = function () {
    }

    return {
        onload : function () {
            init();
//          tdzzs.windowResize();
            tdzzs.tableData();
            tdzzs.checkoutAll()
        },
       //页面缩放效果
       windowResize:function(){
	       	var content_xxcj_h=$(document).height()-20;
			$(".wxl_syxxcj_box").css("height",content_xxcj_h+"px");
       },
       /*表格数据交互*/
      tableData: function() {
 		var data = [{
 				"number": "001",
 				"landLocation": "郑州市金水区",
 				"qiuNum": "4444",
 				"landOrgan": "郑州市土地局",
 				"operation": null
 			},
 			{
 				"number": "002",
 				"landLocation": "郑州市管城区",
 				"qiuNum": "333",
 				"landOrgan": "郑州市土地局",
 				"operation": null
 			}
 		];
 		$('#wxlTdzzs').DataTable({
 			"data": data,
 			"columnDefs": [{
 					"targets": -1,
 					"data": null,
 					"render": function(data, type, full, meta) {
 						return '<a href="tdzzsysxx.html"><span class="btn wxl_bg_yel">变更</span></a>'
 					}
 				},
 				{
 					'targets': 0,
 					'className': 'dt-body-center',
 					'render': function(data, type, row) {
 						return '<input class="checkchild" type="checkbox"/>';
 					}
 				}
 			],
 			"columns": [
 			    {
 					"data": "btn"
 				},
 			    {
 					"data": "number"
 				},
 				{
 					"data": "landLocation"
 				},
 				{
 					"data": "qiuNum"
 				},
 				{
 					"data": "landOrgan"
 				},
 				{
 					"data": "operation"
 				}
 			],
// 			"paging": false,
 			"info": false,
 			"lengthChange": false,
 			"searching": false
 		});
      },
      /*table表格全选*/
     checkoutAll:function(){
         $('.checkall').on('click', function () {
               if (this.checked) {
                    $(this).attr('checked','checked')
                    $('.checkchild').each(function () {
                        this.checked = true;                        
                    });
                } else {
                    $(this).removeAttr('checked')
                    $('.checkchild').each(function () {
                        this.checked = false;
                    });
                }                 
        });   
        $('.checkchild').each(function () {
            $(this).click(function(){
            	var checkLen=$("tbody input[type='checkbox']").length;
				var checkSelect=$("tbody input[type='checkbox']:checked").length;
				if(checkLen==checkSelect){
					$(".checkall").prop("checked",true)
        		}else{
        			$(".checkall").prop("checked",false)
        		}
     		})
        })
    },
     }
})();
